﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PersonalWebSite.Common;

namespace PersonalWebSite.Controllers
{
    public class WallpaperController : BaseController
    {
        [CacheControl(HttpCacheability.NoCache), HttpGet]
        public JsonResult NextWallpaper()
        {
            return Json(new { Path = Url.Content(Wallpaper.FetchNextWallpaperImagesPath()) }, JsonRequestBehavior.AllowGet);
        }

        public FileResult DownloadCurrentWallpaper()
        {
            string filePath = Url.Content(Wallpaper.CurrentWallpaperImagePath);
            return File(filePath, "image/jpg", filePath.Substring(filePath.LastIndexOfAny(new char[]{'\\', '/'}) + 1));
        }
    }
}
